<!--
  -    Copyright (c) 2018-2025, hycloud All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions are met:
  -
  - Redistributions of source code must retain the above copyright notice,
  - this list of conditions and the following disclaimer.
  - Redistributions in binary form must reproduce the above copyright
  - notice, this list of conditions and the following disclaimer in the
  - documentation and/or other materials provided with the distribution.
  - Neither the name of the pig4cloud.com developer nor the names of its
  - contributors may be used to endorse or promote products derived from
  - this software without specific prior written permission.
  - Author: hycloud
  -->
<template>
    <div class="execution">
        <basic-container>
            <avue-crud ref="crud"
                v-model="form"
                :data="tableData"
                :permission="permissionList"
                 @search-change="searchChange"
                :table-loading="tableLoading"
                :option="tableOption"
                @on-load="getList">
                 <template slot="attachment"  slot-scope="scope" v-if="(JSON.parse(scope.row.attachment) instanceof Array)">
                    <div v-for="(item,index) in JSON.parse(scope.row.attachment)" :key="index" class="underline-block">
                        <a :href="item.url" :download="item.original">{{item.original}}</a>
                    </div>
                </template>
                <template slot="timeRange"  slot-scope="scope">
                    <div>{{scope.row.startDate}} 至 {{scope.row.endDate}}</div>
                </template>
            </avue-crud>
        </basic-container>
    </div>
</template>

<script>
    import {fetchReport} from '@/api/housing/housingpayment'
    import {tableOption2} from '@/const/crud/housing/housingpayment'
    import {mapGetters} from 'vuex'

    export default {
        name: 'housingpayment',
        data() {
            return {
                form: {},
                searchForm: {},
                tableData: [],
                tableLoading: false,
                tableOption: tableOption2
            }
        },
        computed: {
            ...mapGetters(['permissions']),
            permissionList() {
                return {
                    addBtn: false,
                    delBtn: false,
                    editBtn:  false
                };
            }
        },
        methods: {
            getList(params) {
                this.tableLoading = true
                fetchReport(Object.assign({
                }, params, this.searchForm )).then(response => {
                    this.tableData = response.data.data.paymentList
                    this.tableLoading = false
                }).catch(() => {
                    this.tableLoading=false
                })
            },
            searchChange(form, done) {
            this.searchForm = form
            this.getList(form)
            done()
            },
        }
    }
</script>